﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FortuneHeaven.BLL.NetBar;
using Jzy.Core.Common.Web;
using Jzy.Core.Common;
using Jzy.Common;
using Jzy.Core.Common.Basic;
using FortuneHeaven.Entity.NetBar;
using Jzy.Core.Utility;

namespace FortuneHeaven.Admin.Pages.NetBar
{
    public partial class RechargeList : PageList
    {

        private string NetBarID
        {
            get
            {
                return Request.QueryString["NetBarID"];
            }
        }
       

        private RechargeHistoryBO RechargeHistory
        {
            get
            {
                return RechargeHistoryBO.Instance<RechargeHistoryBO>();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDrp();
                BindView();
            }
            base.InitSelectID(hidSelectIDs);
            AddAttr();
        }

        private void BindDrp()
        {
            NetBarBO netbar = new NetBarBO();
            List<NetBarInfo> list = new List<NetBarInfo>();
            drpNetBar.DataSource = list;
            drpNetBar.DataTextField = "NetBarName";
            drpNetBar.DataValueField = "ID";
            drpNetBar.DataBind();

            if (!string.IsNullOrEmpty(NetBarID))
            {
                drpNetBar.SelectedValue = NetBarID;
            }
        }

        private void BindView()
        {
            LVUtil.Init(lv, lvHeader);
            PagerSetting setting = new PagerSetting();
            setting.PageIndex = this.PageIndex;
            setting.PageSize = AppConfig.PageSize;
            setting.OrderBy = "InputTime desc";



            string prefix = GlobalVar.WebCurrPath + "List.aspx?NetBarID=" + drpNetBar.SelectedValue;
            List<RechargeHistoryInfo> list = this.RechargeHistory.GetList(setting, drpNetBar.SelectedValue);
            lv.DataKeyNames = new string[] { "ID" };
            lv.DataSource = list;
            lv.DataBind();

            litPager.Text = HtmlPager.Render(setting, prefix, true);

        }

        private void AddAttr()
        {
            
        }

        protected void btnRefresh_Click(object sender, EventArgs e)
        {
            BindView();
        }

        protected void lv_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                //LVUtil.SetEdit(sender, e, 300, 201, GlobalVar.WebCurrPath + "UserEdit.aspx?OperationMode=" + this.Encrypt((int)this.Operation));

            }
        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            BindView();
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (strSelectIDs != "")
            {
                this.RechargeHistory.Delete(StrUtil.SplitToStr(strSelectIDs));
            }
            BindView();
        }
        protected void btnStartup_Click(object sender, EventArgs e)
        {
            List<int> lstMemberIDs = StrUtil.SplitToInt(strSelectIDs);
            //this.NetBar.Startup(lstMemberIDs);
            BindView();
        }

        protected void btnStop_Click(object sender, EventArgs e)
        {
            List<int> lstMemberIDs = StrUtil.SplitToInt(strSelectIDs);
            // NetBar.Stop(lstMemberIDs);
            BindView();
        }

      

        protected void drpNetBar_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}